local lsp_junbian = fk.CreateSkill {
    name = "lsp_junbian",
}

Fk:loadTranslationTable {
    ["lsp_junbian"] = "聚变",
    [":lsp_junbian"] = "有角色受到属性伤害后，你获得伤害值等量的能量值；若你至少拥有3点能量值，你可以移去三点能量，对一名角色造成一点伤害。",

    ["@lsp_junbian"] = "聚变",
}

lsp_junbian:addEffect(fk.Damaged, {
    anim_type = "support",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(lsp_junbian.name) and not target.dead and data.damageType ~= fk.NormalDamage
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local room = player.room
        room:addPlayerMark(player, "@lsp_junbian", data.damage)
        if player:getMark("@lsp_junbian") > 2 then
            local to = room:askToChoosePlayers(player, {
                min_num = 1,
                max_num = 1,
                targets = room:getOtherPlayers(player),
                skill_name = lsp_junbian.name,
                prompt = "聚变：你可以对一名角色造成一点伤害",
                cancelable = true,
            })
            if #to > 0 then
                room:damage {
                    from = player,
                    to = to,
                    damage = 1,
                    skillName = lsp_junbian.name,
                }
                room:removePlayerMark(player, "@lsp_junbian", 3)
            end
        end
    end,
})

return lsp_junbian
